package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	engine := gin.Default()
	engine.GET("/json1", func(context *gin.Context) {
		//手动拼接JSON串
		context.JSON(http.StatusOK, gin.H{"name": "张三", "age": 24})
	})

	engine.GET("/json2", func(context *gin.Context) {
		//使用结构体方式
		context.JSON(http.StatusOK, Student{"Pete", 12})
	})

	engine.Run("127.0.0.1:8088")
}

type Student struct {
	Name string `json:"name"`
	Age  int    `json:"age"`
}
